﻿using DailyNote.AppCode;
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace DailyNote
{
    static class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                #region
                for (int i = 0; i < args.Length; i++)
                {
                    string command = args[i];
                    MainFrm mainForm = new MainFrm();
                    switch (command)
                    {
                        case "/del": //清空数据库
                            if (mainForm.mutex != null)
                            {
                                try
                                {
                                    SQLiteDBHelper.ExecuteNonQuery("delete from note");
                                }
                                catch
                                {
                                    return;
                                }
                            }
                            break;
                        case "/exit":
                            if (mainForm.mutex != null)
                            {
                                Application.Exit();
                                GC.Collect();
                            }
                            break;
                    }
                }
                #endregion
            }
            else
            {
                #region
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                MainFrm frm = new MainFrm();
                if (frm.mutex != null)
                {
                    Application.Run(frm);
                }
                else
                {
                    MessageBox.Show(frm, "程序已经有一个实例在运行！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                #endregion
            }
        }
    }
}
